//
//  E7AnimationGameName.cpp
//  EndlessBattle
//
//  Created by cc on 12-4-30.
//  Copyright (c) 2012年 PalmGame. All rights reserved.
//

#include "E7AnimationGameName.h"

CE7AnimationGameName::CE7AnimationGameName()
{
}

CE7AnimationGameName::~CE7AnimationGameName()
{
}

void CE7AnimationGameName::Init(const char* filename)
{
    m_eID = ANI_GAMENAME ;
    m_bIsLoop = false ;
    m_nFrameMax = 10 ;
    m_fInterval = 0.1f ;

    m_pSheet = CCSpriteBatchNode::batchNodeWithFile(filename) ;
    float w = m_pSheet->getTexture()->getContentSize().width ;
    float h = m_pSheet->getTexture()->getContentSize().height ;

    if (IsPad())
    {
        // 536, 258.
        float init_x = 522.0f ;
        float init_y = 650.0f ;
        float offsetx = (w / 2) / (m_nFrameMax-1) ;
        m_pFrames = new CE7FrameInfo[m_nFrameMax] ;
        for (int i = 0; i < m_nFrameMax; ++i)
        {
            m_pFrames[i].SetInfo(m_pSheet, 
                                 CCRectMake(0, 0, offsetx*i, h), CCPointMake(init_x-offsetx*i/2, init_y),
                                 CCRectMake(w-offsetx*i, 0, offsetx*i, h), CCPointMake(init_x+offsetx*i/2, init_y)) ;
        }
    }
    else
    {
        // 536, 258.
        float init_x = 522.0f/2 - 30.0f ;
        float init_y = 650.0f/2 - 80.0f ;
        float offsetx = (w / 2) / (m_nFrameMax-1) ;
        m_pFrames = new CE7FrameInfo[m_nFrameMax] ;
        for (int i = 0; i < m_nFrameMax; ++i)
        {
            m_pFrames[i].SetInfo(m_pSheet, 
                                 CCRectMake(0, 0, offsetx*i, h), CCPointMake(init_x-offsetx*i/2, init_y),
                                 CCRectMake(w-offsetx*i, 0, offsetx*i, h), CCPointMake(init_x+offsetx*i/2, init_y)) ;
        }
    }
}

                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
